package weekMatch.one_339;

public class LeeCode_01 {
    public static void main(String[] args) {
        System.out.println(kItemsWithMaximumSum(3, 2, 0, 2));
    }

    private static int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) {
        int ans = 0;
        if (k > numOnes) {
            k -= numOnes;
            ans += numOnes;
        } else {
            ans += k;
            k = 0;
        }
        if (k != 0 && numZeros != 0) {
            k -= Math.min(numZeros, k);
            if (numZeros < k)
                numNegOnes = 0;
        }
        if (k != 0) {
            ans -= k;
        }
        return ans;
    }
}
